import math

from simplefactory.cashsuper import CashSuper


# 满减类
class CashReturn(CashSuper):
    moneyCondition = 0
    moneyReturn = 0

    def __init__(self, moneyCondition, moneyReturn):
        self.moneyCondition = moneyCondition
        self.moneyReturn = moneyReturn
        super().__init__()

    def acceptCash(self, money):
        ret = money
        if money >= self.moneyCondition:
            ret = money - math.floor(money / self.moneyCondition) * self.moneyReturn
        return ret
